package com.example.home.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.example.constants.Constants;
import com.example.home.R;
import com.example.home.R2;
import com.example.interfaces.IService;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = Constants.HOME_ACTIVITY_URL)
public class HomeMainActivity extends AppCompatActivity{

    @BindView(R2.id.tv_title)
    TextView tvTitle;

    @Autowired(name = Constants.JUMP_TARGRT_ACTIVIT_UTL)
    IService service;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_main);
        ButterKnife.bind(this);
        ARouter.getInstance().inject(this);
        tvTitle.setText(getIntent().getStringExtra("home")+"");
    }


    @OnClick({R2.id.tv_title,R2.id.btn_service,R2.id.btn_chat})
    public void onClick(View view){
        if(view.getId() == R.id.tv_title){
            ARouter.getInstance()
                    .build("/chat/main")
                    .withString("chat","我喜欢和女生聊天！")
                    .navigation();
        }else if(view.getId() == R.id.btn_service){
            service.sayHello(this);
        }else if(view.getId() == R.id.btn_chat){
            service.jumpActivity(this,"/chat/main","chat","我喜欢和女生聊天！");
        }
    }
}
